﻿<script type="text/javascript">
<!--
	$(function(){
		$('#fatherInfo').hide();
		$('#motherInfo').hide();
		$('#guardianInfo').show();
		$('#showGuardian').attr('checked',true);
		$('#showGuardian').attr('disabled',true);
		$('#showFather').click(function(){
			$('#fatherInfo').toggle();
		});
		$('#showMother').click(function(){
			$('#motherInfo').toggle();
		});

		$('#fillFather').change(function(){
			if($('#fillFather').attr('checked')){
				if($('#showFather').attr('checked')){
					$('#guardianName').val($('#fatherName').val());
					$('#guardianAddress').val($('#fatherAddress').val());
					$('#guardianLandPhone').val($('#fatherLandPhone').val());
					$('#guardianMobilePhone').val($('#fatherMobilePhone').val());
					$('#guardianEmail').val($('#fatherEmail').val());
					$('#guardianFax').val($('#fatherFax').val());
					$('#guardianOccupation').val($('#fatherOccupation').val());
					$('#guardianOfficeAddress').val($('#fatherOfficeAddress').val());
					$('#guardianOfficePhone').val($('#fatherOfficePhone').val());
					$('#guardianOfficeMobilePhone').val($('#fatherOfficeMobilePhone').val());
					$('#guardianOfficeEmail').val($('#fatherOfficeEmail').val());
					$('#guardianOfficeFax').val($('#fatherOfficeFax').val());
				}else{
					alert("පළමුව පියාගේ විස්තර සම්පූර්ණ කරන්න.");
					$('#other').attr('checked',true);
					clearGuardian();
				}
			}
		});
		$('#fillMother').change(function(){
			if($('#fillMother').attr('checked')){
				if($('#showMother').attr('checked')){
					$('#guardianName').val($('#motherName').val());
					$('#guardianAddress').val($('#motherAddress').val());
					$('#guardianLandPhone').val($('#motherLandPhone').val());
					$('#guardianMobilePhone').val($('#motherMobilePhone').val());
					$('#guardianEmail').val($('#motherEmail').val());
					$('#guardianFax').val($('#motherFax').val());
					$('#guardianOccupation').val($('#motherOccupation').val());
					$('#guardianOfficeAddress').val($('#motherOfficeAddress').val());
					$('#guardianOfficePhone').val($('#motherOfficePhone').val());
					$('#guardianOfficeMobilePhone').val($('#motherOfficeMobilePhone').val());
					$('#guardianOfficeEmail').val($('#motherOfficeEmail').val());
					$('#guardianOfficeFax').val($('#motherOfficeFax').val());
				}else{
					alert("පළමුව මවගේ විස්තර සම්පූර්ණ කරන්න.");
					$('#other').attr('checked',true);
					clearGuardian();
				}
			}
		});
		
		$('#addStudentForm').validate({
			rules:{
				studentIndex:{
					required: true
				},
				studentNameWithInitials:{
					required: true
				},
				studentFullName:{
					required: true
				},
				studentDateOfBirth:{
					required: true,
					date: true
				},
				address:{
					required: true
				},
				guardianName:{
					required: true
				},
				guardianAddress:{
					required: true
				}
			},
			messages:{
				studentIndex:{
					required: 'ඇතුල්වීමේ අංකය  ඇතුලත් කරන්න'
				},
				studentNameWithInitials:{
					required: 'මුලකුරු සමඟ නම ඇතුලත් කරන්න'
				},
				studentFullName:{
					required: 'සම්පූර්ණ නම ඇතුලත් කරන්න'
				},
				studentDateOfBirth:{
					required: 'උපන් දිනය ඇතුලත් කරන්න',
					date: 'නිවැරදි දිනයක් තෝරන්න'
				},
				address:{
					required: 'ස්ථීර ලිපිනය ඇතුලත් කරන්න'
				},
				guardianName:{
					required: 'භාරකරුගේ නම ඇතුලත් කරන්න'
				},
				guardianAddress:{
					required: 'භාරකරුගේ ස්ථීර ලිපිනය ඇතුලත් කරන්න'
				}
			}
		});
	});

	function clearGuardian(){
		$('#guardianName').val('');
		$('#guardianAddress').val('');
		$('#guardianLandPhone').val('');
		$('#guardianMobilePhone').val('');
		$('#guardianEmail').val('');
		$('#guardianFax').val('');
		$('#guardianOccupation').val('');
		$('#guardianOfficeAddress').val('');
		$('#guardianOfficePhone').val('');
		$('#guardianOfficeMobilePhone').val('');
		$('#guardianOfficeEmail').val('');
		$('#guardianOfficeFax').val('');
	}
//-->
</script>

<div class="content-title">
	<h3>ශිෂ්‍ය තොරතුරු ඇතුළත් කිරීම</h3>
</div>
<hr/>
<div class="web-form">		
	<?php if($_SESSION['log-err']) { ?>
		<div class="log-err">
			<?php echo $_SESSION['log-err'];?>
		</div>
	<?php }
		if($_SESSION['log-info']){ ?>
		<div class="log-info">
			<?php echo $_SESSION['log-info'];?>
		</div>	
	<?php } ?>
	<form id="addStudentForm" action="./system/addStudent.php" method="POST">
		<fieldset>
			<legend>සිසුවාගේ තොරතුරු</legend>
			<table class="width-100">
				<tr>
					<td>ඇතුල්වීමේ අංකය <span class="mandatory"> * </span></td>
					<td colspan="3"><input type="text" name="studentIndex" id="studentIndex" class="width-200"/></td>
				</tr>
				<tr>
					<td>මුලකුරු සමඟ නම <span class="mandatory"> * </span></td>
					<td colspan="3"><textarea id="studentNameWithInitials" rows="1" name="studentNameWithInitials" class="width-675"></textarea></td>
				</tr>
				<tr>
					<td>සම්පූර්ණ නම <span class="mandatory"> * </span></td>
					<td colspan="3"><textarea id="studentFullName" rows="1" name="studentFullName" class="width-675"></textarea></td>
				</tr>
				<tr>
					<td>ස්ත්‍රී පුරුෂ භාවය</td>
					<td>
						<select name="studentGender" class="width-200">
							<option value="පුරුෂ">පුරුෂ</option>
							<option value="ස්ත්‍රී">ස්ත්‍රී</option>
						</select>
					</td>
					<td>උපන් දිනය <span class="mandatory"> * </span></td>
					<td><input id="studentDateOfBirth" type="text" name="studentDateOfBirth" class="width-200 datePicker" /></td>
				</tr>
				<tr>
					<td>ස්ථීර ලිපිනය <span class="mandatory"> * </span></td>
					<td colspan="3"><textarea id="address" rows="1" name="address" class="width-675"></textarea></td>
				</tr>
				<tr>
					<td>දුරකථන අංක</td>
					<td colspan="3">
						<table>
							<tr>
								<td>නිවස</td>
								<td><input type="text" name="landPhone" class="width-200"/></td>
							</tr>
							<tr>
								<td>ජංගම</td>
								<td><input type="text" name="mobilePhone" class="width-200"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>ඉ-තැපැල් ලිපිනය</td>
					<td><input type="text" name="email" class="width-200"/></td>
					<td>ෆැක්ස් ලිපිනය</td>
					<td><input type="text" name="fax" class="width-200"/></td>
				</tr>
				<tr>
					<td>විශේෂ රෝගී තත්ත්වයන්</td>
					<td colspan="3"><textarea rows="1" name="studentHealthInfo" class="width-675"></textarea></td>
				</tr>
				<tr>
					<td>විශේෂ කුසලතා</td>
					<td colspan="3"><textarea rows="1" name="studentSpecialSkills" class="width-675"></textarea></td>
				</tr>
			</table>
		</fieldset>
		<div id="showFMG" class="width-100 align-center">
			<input id="showFather" type="checkbox"/>
			<label for="showFather">පියාගේ තොරතුරු</label>	
			<input id="showMother" type="checkbox"/>
			<label for="showMother">මවගේ තොරතුරු</label>	
			<input id="showGuardian" type="checkbox"/>
			<label for="showGuardian"><span class="mandatory"> * </span>භාරකරුගේ තොරතුරු</label>	
		</div>
		<fieldset id="fatherInfo" class="info">
			<legend>පියාගේ තොරතුරු</legend>
			<table class="width-100">
				<tr>
					<td>පියාගේ නම</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="fatherName" id="fatherName"></textarea></td>
				</tr>
				<tr>
					<td>පියාගේ ස්ථීර ලිපිනය</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="fatherAddress" id="fatherAddress"></textarea></td>
				</tr>
				<tr>
					<td>පියාගේ දුරකථන අංක</td>
					<td colspan="3">
						<table>
							<tr>
								<td>නිවස</td>
								<td><input type="text" name="fatherLandPhone" id="fatherLandPhone" class="width-200"/></td>
							</tr>
							<tr>
								<td>ජංගම</td>
								<td><input type="text" name="fatherMobilePhone" id="fatherMobilePhone" class="width-200"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>ඉ-තැපැල් ලිපිනය</td>
					<td><input type="text" name="fatherEmail" id="fatherEmail" class="width-200"/></td>
					<td>ෆැක්ස් ලිපිනය</td>
					<td><input type="text" name="fatherFax" id="fatherFax" class="width-200"/></td>
				</tr>
				<tr>
					<td>පියාගේ රැකියාව</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="fatherOccupation" id="fatherOccupation"></textarea></td>
				</tr>
				<tr>
					<td>රැකියා ස්ථානයේ ලිපිනය</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="fatherOfficeAddress" id="fatherOfficeAddress"></textarea></td>
				</tr>
				<tr>
					<td>රැකියා ස්ථානයේ දුරකථන අංක</td>
					<td colspan="3">
						<table>
							<tr>
								<td>කාර්යාලයීය</td>
								<td><input type="text" name="fatherOfficePhone" id="fatherOfficePhone" class="width-200"/></td>
							</tr>
							<tr>
								<td>ජංගම</td>
								<td><input type="text" name="fatherOfficeMobilePhone" id="fatherOfficeMobilePhone" class="width-200"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>ඉ-තැපැල් ලිපිනය</td>
					<td><input type="text" name="fatherOfficeEmail" id="fatherOfficeEmail" class="width-200"/></td>
					<td>ෆැක්ස් ලිපිනය</td>
					<td><input type="text" name="fatherOfficeFax" id="fatherOfficeFax" class="width-200"/></td>
				</tr>
			</table>
		</fieldset>
		<fieldset id="motherInfo" class="info">
			<legend>මවගේ තොරතුරු</legend>
			<table class="width-100">
				<tr>
					<td>මවගේ නම</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="motherName" id="motherName"></textarea></td>
				</tr>
				<tr>
					<td>මවගේ ස්ථීර ලිපිනය</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="motherAddress" id="motherAddress"></textarea></td>
				</tr>
				<tr>
					<td>මවගේ දුරකථන අංක</td>
					<td colspan="3">
						<table>
							<tr>
								<td>නිවස</td>
								<td><input type="text" name="motherLandPhone" id="motherLandPhone" class="width-200"/></td>
							</tr>
							<tr>
								<td>ජංගම</td>
								<td><input type="text" name="motherMobilePhone" id="motherMobilePhone" class="width-200"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>ඉ-තැපැල් ලිපිනය</td>
					<td><input type="text" name="motherEmail" id="motherEmail" class="width-200"/></td>
					<td>ෆැක්ස් ලිපිනය</td>
					<td><input type="text" name="motherFax" id="motherFax" class="width-200"/></td>
				</tr>
				<tr>
					<td>මවගේ රැකියාව</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="motherOccupation" id="motherOccupation"></textarea></td>
				</tr>
				<tr>
					<td>රැකියා ස්ථානයේ ලිපිනය</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="motherOfficeAddress" id="motherOfficeAddress"></textarea></td>
				</tr>
				<tr>
					<td>රැකියා ස්ථානයේ දුරකථන අංක</td>
					<td colspan="3">
						<table>
							<tr>
								<td>කාර්යාලයීය</td>
								<td><input type="text" name="motherOfficePhone" id="motherOfficePhone" class="width-200"/></td>
							</tr>
							<tr>
								<td>ජංගම</td>
								<td><input type="text" name="motherOfficeMobilePhone" id="motherOfficeMobilePhone" class="width-200"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>ඉ-තැපැල් ලිපිනය</td>
					<td><input type="text" name="motherOfficeEmail" id="motherOfficeEmail" class="width-200"/></td>
					<td>ෆැක්ස් ලිපිනය</td>
					<td><input type="text" name="motherOfficeFax" id="motherOfficeFax" class="width-200"/></td>
				</tr>
			</table>
		</fieldset>
		<fieldset id="guardianInfo" class="info">
			<legend>භාරකරුගේ තොරතුරු <span class="mandatory"> * </span></legend>
			<table class="width-100">
				<tr>
					<td colspan="4" align="center">
						<input id="fillFather" type="radio" name="guardian"/>
						<label for="fillFather">පියා</label>	
						<input id="fillMother" type="radio" name="guardian"/>
						<label for="fillMother">මව</label>	
						<input id="other" type="radio" name="guardian"/>
						<label for="other">වෙනත්</label>
					</td>
				</tr>
				<tr>
					<td>භාරකරුගේ නම <span class="mandatory"> * </span></td>
					<td colspan="3"><textarea rows="1" class="width-675" name="guardianName" id="guardianName"></textarea></td>
				</tr>
				<tr>
					<td>ස්ථීර ලිපිනය <span class="mandatory"> * </span></td>
					<td colspan="3"><textarea rows="1" class="width-675" name="guardianAddress" id="guardianAddress"></textarea></td>
				</tr>
				<tr>
					<td>භාරකරුගේ දුරකථන අංක</td>
					<td colspan="3">
						<table>
							<tr>
								<td>නිවස</td>
								<td><input type="text" name="guardianLandPhone" id="guardianLandPhone" class="width-200"/></td>
							</tr>
							<tr>
								<td>ජංගම</td>
								<td><input type="text" name="guardianMobilePhone" id="guardianMobilePhone" class="width-200"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>ඉ-තැපැල් ලිපිනය</td>
					<td><input type="text" name="guardianEmail" id="guardianEmail" class="width-200"/></td>
					<td>ෆැක්ස් ලිපිනය</td>
					<td><input type="text" name="guardianFax" id="guardianFax" class="width-200"/></td>
				</tr>
				<tr>
					<td>භාරකරුගේ රැකියාව</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="guardianOccupation" id="guardianOccupation"></textarea></td>
				</tr>
				<tr>
					<td>රැකියා ස්ථානයේ ලිපිනය</td>
					<td colspan="3"><textarea rows="1" class="width-675" name="guardianOfficeAddress" id="guardianOfficeAddress"></textarea></td>
				</tr>
				<tr>
					<td>රැකියා ස්ථානයේ දුරකථන අංක</td>
					<td colspan="3">
						<table>
							<tr>
								<td>කාර්යාලයීය</td>
								<td><input type="text" name="guardianOfficePhone" id="guardianOfficePhone" class="width-200"/></td>
							</tr>
							<tr>
								<td>ජංගම</td>
								<td><input type="text" name="guardianOfficeMobilePhone" id="guardianOfficeMobilePhone" class="width-200"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>ඉ-තැපැල් ලිපිනය</td>
					<td><input type="text" name="guardianOfficeEmail" id="guardianOfficeEmail" class="width-200"/></td>
					<td>ෆැක්ස් ලිපිනය</td>
					<td><input type="text" name="guardianOfficeFax" id="guardianOfficeFax" class="width-200"/></td>
				</tr>
			</table>
		</fieldset>
		<hr/>
		<div class="form-buttons">
			<button id="cancelButton" name="cancelButton" type="submit" class="web-form-button cancel">
				<img src="./public/images/cancel.png">
				<span>අවලංගු කරන්න</span>
			</button>
			<button id="resetButton" name="resetButton" type="reset" class="web-form-button cancel">
				<img src="./public/images/reset.png">
				<span>යලි පිහිටුවන්න</span>
			</button>
			<button id="addStudentButton" name="addStudentButton" type="submit" class="web-form-button">
				<img src="./public/images/add_student.png">
				<span>ඇතුලත් කරන්න</span>
			</button>
		</div>
	</form>
</div>